package com.nurdrobotics;

import edu.wpi.first.wpilibj.*;

/**
 * Controls a tricolor LED connected to PWM outputs.
 */
public class SignalLED {
    // Static constants for setColor.  Note that the JVM on the robot does not
    // support enum types.
    public static final int OFF = 0;
    public static final int RED = 1;
    public static final int WHITE = 2;
    public static final int BLUE = 3;

    // pwm objects for each color
    PWM redLED;
    PWM greenLED;
    PWM blueLED;
    
    protected SignalLED(int redPWMPort, int greenPWMPort, int bluePWMPort){
        redLED = new PWM(redPWMPort);
        greenLED = new PWM(greenPWMPort);
        blueLED = new PWM(bluePWMPort);
    }

    /**
     * Constructs a signal led with PWM ports 5, 6, and 7 for red, green, and
     * blue respectively
     */
    public SignalLED(){
        this(5, 6, 7);
    }

    /**
     * Sets the led color.
     * @param color see static class variables
     */
    public void setColor(int color){
        System.out.print("Signal LED set to: ");
        switch(color){
            case RED:
                System.out.println("RED");
                redLED.setRaw(255);
                greenLED.setRaw(0);
                blueLED.setRaw(0);
                break;
            case WHITE:
                System.out.println("WHITE");
                redLED.setRaw(255);
                greenLED.setRaw(255);
                blueLED.setRaw(100);
                break;
            case BLUE:
                System.out.println("BLUE");
                redLED.setRaw(0);
                greenLED.setRaw(0);
                blueLED.setRaw(255);
                break;
            default:
                System.out.println("OFF");
                redLED.setRaw(0);
                greenLED.setRaw(0);
                blueLED.setRaw(0);
                break;
        }
    }
}
